<script>

$(function() {

  var thisDay = new Date().getDay();
  if (thisDay == 0) {
    thisDay = 6;
  } else{
    thisDay -= 1;
  }
  $(".datepicker-entry").datepicker({
    format: "yyyy-mm-dd",
    startView: "month",
    startDate: "-"+thisDay+"d",
    endDate: "0",
    weekStart: "1",
    autoclose: true,
    todayHighlight: true
  });

});
</script>


<div class="well">
  <div class="nested-fields">

    <h4 style="color:green">Income new entry</h4>

  <div class="form-group">
    <label class="col-sm-2 control-label">Source</label>
    <div class="col-sm-8">
      <%= f.collection_select(:income_id, @income, :id, :source, {:include_blank => "Select income"}, {:class => "entry-source-select form-control", :alt => "income"} ) %>
    </div>
  </div>

  <div class="entry-fields">
    <!--%= render 'income_fields' %-->
  </div>

  
  <div class="entry-data-section" style="display:none">
  <div class="form-group">
    <label class="col-sm-2 control-label">Date</label>
    <div class="col-sm-8">
      <div class="input-group date datepicker-entry">
        <%= f.text_field :trans_date, :class=>"form-control", :placeholder=>"yyyy-mm-dd" %>
        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
      </div>
    </div>
  </div>
  <div class="entry-data-input">
    <div class="form-group">
      <label class="col-sm-2 control-label">Duration</label>
      <div class="col-sm-8">
        <% duration = [['120 min', 8], ['105 min', 7], ['90 min', 6], ['75 min', 5], ['60 min', 4], ['45 min', 3], ['30 min', 2], ['15 min', 1]] %>
        <%= f.select(:duration, duration, {:include_blank => "Select duration"}, {:class => "form-control entry-duration-select"} ) %>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label">Level</label>
      <div class="col-sm-8">
        <% level = [['Full 100%', 4], ['High 75%', 3], ['Med 50%', 2], ['Lite 25%', 1]] %>
        <%= f.select(:level, level, {:include_blank => "Select level"}, {:class => "form-control entry-level-select"} ) %>
      </div>
    </div>
  </div>

  <div class="form-group">
    <label class="col-sm-2 control-label">Note</label>
    <div class="col-sm-8">
      <%= f.text_area :description, :class=>"form-control", :placeholder=>"Optional" %>
    </div>
  </div>
  </div>

  <div class="entry-data-amount">
  <div class="form-group">
    <label class="col-sm-2 control-label">Earn</label>
    <div class="col-sm-8">
      <h4><span class="label label-success">0</span></h4>
    </div>
    <%= f.hidden_field :amount, :value => 0 %>
  </div>
  </div>
  
  <%= link_to_remove_association "Remove Entry", f %>

  </div>
</div>
